package com.zhang.common.jpa.entity.impl;

import com.zhang.common.jpa.entity.PageCmd;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;

import javax.validation.constraints.NotNull;

@Data
public class BasePageCmd implements PageCmd {


    @NotNull(message = "分页页码不能为空")
    private Integer pageNum;

    @NotNull(message = "分页大小不能为空")
    private Integer pageSize;


    public Pageable getPage() {
        return PageRequest.of(pageNum - 1,pageSize);
    }
}
